package com.chenjian.service.impl;

import com.chenjian.dao.ArticleDao;
import com.chenjian.entity.ArticleEntity;
import com.chenjian.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

/**
 * @author TC2952
 */
@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleDao articleDao;

    /**
     * 分页查询
     *
     * @param page
     * @param size
     * @return
     */
    @Override
    public Page<ArticleEntity> findByPage(Integer page, Integer size) {
        Sort sort = Sort.by("id").ascending();
        PageRequest request = PageRequest.of(page, size, sort);
        Page<ArticleEntity> all = articleDao.findAll(request);
        return all;
    }
}
